 

#include "item.h"

#include <OgreEntity.h>
#include <OgreMath.h>
#include <OgreVector3.h>

Item::Item(World *world){
    m_world = world;
}

void Item::createModel(){
    Ogre::SceneManager * scene = m_world->getSceneManager();
    Ogre::Entity* ogreHead = scene->createEntity(getModel());

    m_node = scene->getRootSceneNode()->createChildSceneNode();
    m_node->attachObject(ogreHead);
    m_node->scale(0.7,0.7,0.7);
}

void Item::setPosition(Ogre::Vector3 pos){
    m_node->setPosition(pos);
}

void Item::move(float time)
{
    Ogre::Vector3 dir = Ogre::Vector3(0,0,-200);
    m_node->setPosition(m_node->getPosition() + time* dir);
}

void Item::colide(AI *object)
{
    if(!object->isNpc() && object->getType() == TYPE_PLAYER){
        effect((Player *) object);
        m_world->removeActor(this);
    }
}

void Item::destroy()
{
    m_node->getParent()->removeChild(m_node);
    delete m_node;
}
